package com.ssyt.store.sys.dao.impl;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Date;

import org.springframework.stereotype.Repository;

import com.ssyt.store.common.BaseDao;
import com.ssyt.store.common.EasyUIPageModel;
import com.ssyt.store.sys.dao.SysLogDao;
import com.ssyt.store.sys.entity.SysLogEntity;

@Repository
public class SysLogDaoImpl extends BaseDao<SysLogEntity, Integer> implements SysLogDao {



	@Override
	public EasyUIPageModel<SysLogEntity> listLogs(int page, int rows) {
		return pageEntityByHqlEasyUI(page, rows, "FROM SysLogEntity ORDER BY operateTime DESC");
	}

	@Override
	public void addLogs(String operation,String userId) {
		String ip = "";
		try {
			ip = InetAddress.getLocalHost().toString();
		} catch (UnknownHostException e) {
			e.printStackTrace();
		}
		SysLogEntity log = new SysLogEntity();
		log.setOperation(operation);
		log.setIp(ip);
		log.setUserCode(userId);
		log.setOperateTime(new Date());
		save(log);
	}

}
